'use strict';

module.exports = app => {
  const { STRING, UUID, UUIDV4, INTEGER, DECIMAL } = app.Sequelize;

  const model = app.model.define('product', {
    id: {
      type: UUID,
      defaultValue: UUIDV4,
      primaryKey: true,
      comment: 'Id',
    },
    name: {
      type: STRING,
      allowNull: false,
      comment: '名称',
    },
    code: {
      type: STRING,
      allowNull: false,
      comment: '产品编码',
    },
    type: {
      type: STRING,
      comment: '型号',
    },
    price: {
      type: DECIMAL(10,2),
      comment: '采购价',
    },
    guide_price: {
      type: DECIMAL(10,2),
      comment: '指导价',
    },
    min_guide_price: {
      type: DECIMAL(10,2),
      comment: '最低指导价',
    },
    factory: {
      type: STRING,
      comment: '生产厂家',
    },
    remark: {
      type: STRING,
      comment: '备注',
    },
    unit: {
      type: STRING,
      comment: '单位',
    },
    category: {
      type: UUID,
      comment: '产品分类',
    },
  }, {
      tableName: 'product',
      comment: '产品表',
    });

  return model;
};
